//
//  DQLoginViewController.m
//  DQBaisibudejie
//
//  Created by 杜倩 on 16/9/1.
//  Copyright © 2016年 杜倩. All rights reserved.
//

#import "DQLoginViewController.h"
#import "DQLoginView.h"
#import "DQThreeLogin.h"
@interface DQLoginViewController ()
@property (weak, nonatomic) IBOutlet UIView *middleView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *MiddleLeading;//middle.leading=leading的这条线的约束

@property (weak, nonatomic) IBOutlet UIView *bottomView;

@end

@implementation DQLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadLoginAndRegiste];
   // DQLoginView *loginView=[DQLoginView loadLogin];
    
    //设置loginView的大小
//    loginView.frame=CGRectMake(0, 0, self.middleView.frame.size.width/2, self.middleView.frame.size.height);
    
    //[self.middleView addSubview:loginView];//加载登录界面
    
    //DQLoginView *registView=[DQLoginView loadRegist];
    //registView.frame=CGRectMake(self.middleView.frame.size.width/2, 0, self.middleView.frame.size.width/2, self.middleView.frame.size.height);
    //[self.middleView addSubview:registView];//将注册页面加载到中间的view
}

-(void)loadLoginAndRegiste{
    //添加登录
    DQLoginView *loginView=[DQLoginView loadLogin];
        [self.middleView addSubview:loginView];
    //添加注册
    DQLoginView *registView=[DQLoginView loadRegist];
    [self.middleView addSubview:registView];
    //添加第三方登录
    DQThreeLogin *three=[DQThreeLogin threeLogin];
    [self.bottomView addSubview:three];
}

#pragma mark 修改布局
-(void)viewDidLayoutSubviews{
    DQLoginView *loginView=self.middleView.subviews[0];
    loginView.frame=CGRectMake(0, 0, self.middleView.frame.size.width/2, self.middleView.frame.size.height);
    DQLoginView *registView=self.middleView.subviews[1];
    registView.frame=CGRectMake(self.middleView.frame.size.width/2, 0, self.middleView.frame.size.width/2, self.middleView.frame.size.height);
}




#pragma mark 退出
- (IBAction)dismiss:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark 注册账号
- (IBAction)registAccount:(UIButton *)sender {
   
   /* //现在取出frame
    CGRect rect=self.middleView.frame;
    //修改--向左移动的距离
    rect.origin.x -=self.middleView.frame.size.width/2;
    //赋值
    self.middleView.frame=rect;*///---有约束的控件不要去修改它的约束
    sender.selected = !sender.selected;
    //代码修改约束--MiddleLeading
    if (sender.selected) {
        self.MiddleLeading.constant= -self.middleView.frame.size.width/2;
    }else{
        self.MiddleLeading.constant=0;
    }
}

#pragma mark 单例--单击跳转登录界面--2
+(instancetype)allocWithZone:(struct _NSZone *)zone{
    static id instance=nil;
    if (instance == nil) {
        instance = [super allocWithZone:zone];
    }
    return instance;
}


@end
